@extends('users.app')
@section('title', '添加/修改用户')
@section('content')
<div class="col-md-6 offset-md-3">
<div class="card">
<div class="card-header border-bottom">
<h4 class="card-title">@if($member->id)编辑@else添加@endif用户</h4>
</div>
<div class="card-body">
  @include('common.error')
@if($member->id)
<form action="{{ route('members.update', $member->id) }}" method="POST" accept-charset="UTF-8">
  <input type="hidden" name="_method" value="PUT">
@else
<form class="form" action="{{ route('members.store') }}" method="POST" accept-charset="UTF-8">
  @if ($user->hasRole('Daili'))
  <input type="hidden" name="parent_id" value="{{$user->id}}">
  @else
  <input type="hidden" name="parent_id" value="0">
  @endif

@endif
  {{ csrf_field() }}
<div class="form-row">
  @can('destroy', $user)
<div class="form-check col-md-12 m-b-20">
<div class="custom-control custom-radio radio custom-control-inline">
  <input type="radio" class="custom-control-input" name="type" id="male" @if(old('type') === 'daili' || $member->hasRole('Daili')) checked=""@endif value="daili">
  <label class="custom-control-label" for="male">代理</label>
</div>
<div class="custom-control custom-radio radio custom-control-inline">
  <input type="radio" class="custom-control-input" name="type" id="gender" @if(old('type') !== 'daili' && !$member->hasRole('Daili')) checked=""@endif value="member">
  <label class="custom-control-label" for="gender">普通用户</label>
</div>
</div>
@endcan
<div class="form-group col-lg-12">
  <label for="username">用户名</label>
  <input type="text" name="name" class="form-control" id="username" value="{{ old('name', $member->name)}}">

</div>
<div class="form-group col-lg-12">
  <label for="qq">QQ(选填)</label>
<input type="text" name="qq" class="form-control" id="qq"  value="{{ old('qq', $member->qq)}}">

</div>
@can('destroy', $user)
<div class="form-group col-lg-12">
  <label for="kouliang">扣量比例(-1 为使用系统配置的值, 填写整数 10 为扣10%)</label>
  <input type="text" name="kouliang" class="form-control" id="kouliang"  value="{{ old('kouliang', $member->kouliang ?: -1)}}">
</div>
<div class="form-group col-lg-12">
  <label for="kouliang_min">扣量阈值(-1 为使用系统配置的值)</label>
  <input type="text" name="kouliang_min" class="form-control" id="kouliang_min"  value="{{ old('kouliang_min', $member->kouliang_min ?: -1)}}">
</div>
<div class="form-group col-lg-12">
  <label for="price">单价(0 为使用系统配置的值)</label>
  <input type="text" name="price" class="form-control" id="price"  value="{{ old('price', $member->price ?: 0)}}">

</div>
<div class="form-group col-lg-12">
  <label for="parent_id">上级 ID</label>
  <input type="text" name="parent_id" class="form-control" id="parent_id"  value="{{ old('parent_id', $member->parent_id ?: 0)}}">
</div>
@endcan
<div class="form-group col-lg-6">
  <label for="password">密码@if($member->id) (不修改请留空)@endif</label>
  <input type="password" name="password" class="form-control" id="password">

</div>
<div class="form-group col-lg-6">
  <label for="confirmPassword">确认密码</label>
  <input type="password" name="password_confirmation" class="form-control" id="confirmPassword">
</div>
<div class="form-group col-lg-12 text-righ">
<button type="submit" class="btn btn-common">@if($member->id)保存@else创建@endif</button>
</div>
</div>
</form>
</div>
</div>
</div>

@stop
